<template>
  <div class="layout">
    <div class="table-layout">
      <div class="table-header">
        <el-row>
          <el-form ref="queryForm" :inline="true" :model="queryParams" class="demo-form-inline">
            <el-form-item label="案件名称" prop="c12">
              <el-input v-model="queryParams.c12" placeholder="请输入" clearable />
            </el-form-item>
            <el-form-item label="立案时间" prop="c4">
              <el-date-picker
                v-model="queryParams.c4"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择"
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="searchHandle">查询</el-button>
              <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
        </el-row>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              @click="handleAdd()"
            >新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              icon="el-icon-edit"
              size="small"
              :disabled="single"
              @click="handleUpdate"
            >修改</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="small"
              :disabled="multiple"
              @click="handleDelete"
            >删除</el-button>
          </el-col>
        </el-row>
      </div>
      <div class="table-body">
        <el-table :data="tableData" style="width: 100%" height="100%" stripe @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column type="index" label="序号" width="50" />
          <el-table-column align="left" prop="ajmc" label="案件名称" min-width="200" />
          <el-table-column align="center" prop="sah" width="180" label="受案号" />
          <el-table-column align="center" prop="ajlb" label="案件类型" />
          <el-table-column align="center" prop="lasj" label="立案时间" />
          <el-table-column align="center" prop="ysjg" label="移送机关" min-width="120" />
          <el-table-column align="center" prop="ajyjrq" label="案卷移交日期" />
          <!-- <el-table-column align="center" prop="lzzt" label="案件流转状态" /> -->
          <el-table-column align="center" prop="status" label="案件填录环节">
            <!-- 1、公安机关填录2、【法制审核】3、侦协办审查填录4、【分管检察长审批】5、案管部门初审6、检察官办案单元填录） -->
            <template slot-scope="scope">
              <span>{{ ['法制审核','侦协办审查填录','分管检察长审批','案管部门初审','检察官办案单元填录'][scope.row.status ] }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="spqx" label="审批期限" />
          <el-table-column align="center" prop="cjsj" label="创建时间" />
          <el-table-column align="center" label="操作" width="200">
            <template slot-scope="scope">
              <el-link type="warning" class="mr-10" @click="handleAdd(scope.row)">填录</el-link>
              <el-link v-if="scope.row.status==1" type="warning" class="mr-10" @click="handleAdd(scope.row)">编辑</el-link>
              <el-link v-if="scope.row.status==1" type="danger" class="mr-10" @click="handleDelete(scope.row)">删除</el-link>
              <el-popconfirm
                title="是否审核通过？"
                confirm-button-text="通过"
                cancel-button-text="驳回"
              >
                <el-link v-if="scope.row.status==0" slot="reference" type="success" class="mr-10">审核</el-link>
              </el-popconfirm>
              <el-link type="primary" @click="handleDetail(scope.row)">详情</el-link>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="table-footer">
        <pagination
          background
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          :page.sync="pageParams.pageNum"
          :limit.sync="pageParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
    <el-dialog
      title="新增"
      :visible.sync="dialogVisible"
      width="600px"
      custom-class="hasHeight"
      append-to-body
    >
      <form1 ref="addForm" :type="'add'" :show-flag="false" />
      <div slot="footer" class="drawer-footer">
        <el-button @click="dialogVisible=false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
    <el-drawer
      :title="type==='add'?'填录':'详情'"
      :visible.sync="drawerOpen"
      append-to-body
      size="1000px"
      custom-class="dv_drawer"
    >
      <formDetail ref="formBox" :type="type" />
      <div v-if="type==='add'" class="drawer-footer">
        <el-button @click="drawerOpen=false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import formDetail from './form.vue'
import form1 from './component/form1.vue'
import form2 from './component/form2.vue'
import form3 from './component/form3.vue'
import form4 from './component/form4.vue'
import page_common from '@/views/mixins/page_common.js'
export default {
  name: 'Arrest',
  components: {
    form1,
    formDetail
  },
  mixins: [page_common],
  data() {
    return {
      queryParams: { c12: '', c4: '' },
      tableData: [],
      dialogVisible: false,
      drawerOpen: false,
      type: '',
      component: form2
    }
  },
  created() {
    this.searchHandle()
  },
  methods: {
    getList() {
      this.tableData = [
        {
          ajmc: '‌李某涉嫌抢劫罪审查逮捕案‌',
          sah: '（2025）豫0108刑捕0002号',
          ajlb: '审查逮捕',
          ysjg: '郑州市公安局惠济分区',
          lasj: '2025-03-23',
          ajyjrq: '2025-03-24',
          lzzt: '继续侦查',
          spqx: '23小时34分钟',
          cjsj: '2025-03-24',
          status: 1,
          gajgForm: {
            ajmc: '‌王某涉嫌诈骗罪审查逮捕案‌‌',
            sah: '（2025）豫0108刑捕0002号',
            xyrmc: '张某',
            rs: '20',
            lasj: '2025-03-23',
            ay: '涉嫌组织、领导黑社会性质组织罪审查',
            qzcs: '2025-03-24',
            zcjg: '惠济区检察院',
            fzshr: '李某',
            fjrd: ''
          }
        }, {
          ajmc: '‌周某涉嫌贩卖毒品罪审查逮捕案',
          sah: '（2025）豫0108刑捕0002号',
          ajlb: '审查逮捕',
          ysjg: '郑州市公安局惠济分区',
          lasj: '2025-03-23',
          ajyjrq: '2025-03-24',
          lzzt: '继续侦查',
          spqx: '20小时12分钟',
          cjsj: '2025-03-24',
          status: 2,
          gajgForm: {
            ajmc: '‌周某涉嫌贩卖毒品罪审查逮捕案',
            sah: '（2025）豫0108刑捕0001号',
            xyrmc: '张某',
            rs: '20',
            lasj: '2025-03-23',
            ay: '涉嫌贩卖毒品罪',
            qzcs: '2025-03-24',
            zcjg: '惠济区检察院',
            fzshr: '李某',
            fjrd: ''
          }
        }, {
          ajmc: '‌赵某涉嫌故意杀人罪审查逮捕案‌',
          sah: '（2025）豫0108刑捕0002号',
          ajlb: '审查逮捕',
          ysjg: '郑州市公安局惠济分区',
          lasj: '2025-03-21',
          ajyjrq: '2025-03-22',
          lzzt: '继续侦查',
          spqx: '2小时14分钟',
          cjsj: '2025-03-22',
          status: 3,
          gajgForm: {
            ajmc: '‌赵某涉嫌故意杀人罪审查逮捕案‌',
            sah: '（2025）豫0108刑捕0001号',
            xyrmc: '张某',
            rs: '4',
            lasj: '2025-03-21',
            ay: '涉嫌故意杀人罪',
            qzcs: '2025-03-22',
            zcjg: '惠济区检察院',
            fzshr: '李某',
            fjrd: ''
          },
          form1: {
            c1: '1',
            c2: '1',
            c3: '',
            c4: '',
            c5: '1',
            c6: '',
            c7: '1',
            c8: ''
          }
        }, {
          ajmc: '‌王某涉嫌诈骗罪审查逮捕案‌‌',
          sah: '（2025）豫0108刑捕0001号',
          ajlb: '审查逮捕',
          ysjg: '郑州市公安局惠济分区',
          lasj: '2025-03-14',
          ajyjrq: '2025-03-15',
          lzzt: '继续侦查',
          spqx: '12小时34分钟',
          cjsj: '2025-03-16',
          status: 1,
          gajgForm: {
            ajmc: '‌王某涉嫌诈骗罪审查逮捕案‌‌',
            sah: '（2025）豫0108刑捕0001号',
            xyrmc: '张某',
            rs: '20',
            lasj: '2025-03-14',
            ay: '涉嫌诈骗罪',
            qzcs: '2025-01-15',
            zcjg: '惠济区检察院',
            fzshr: '李某',
            fjrd: ''
          }
        }

      ]
    },
    handleAdd(rowData) {
      this.type = 'add'
      if (!rowData) {
        this.dialogVisible = true
        this.$nextTick(() => {
          this.$refs.addForm.init()
        })
        return
      }
      this.drawerOpen = true
      const arr = [form2, form3, form4]
      this.component = arr[rowData.status]
      this.$nextTick(() => {
        console.log(rowData)
        this.$refs.formBox.init(rowData, 'add')
      })
    },
    handleUpdate(rowData) {

    },
    handleDelete(rowData) {

    },
    handleDetail(rowData) {
      this.type = 'detail'
      this.drawerOpen = true
      this.component = formDetail
      this.$nextTick(() => {
        this.$refs.formBox.init(rowData, 'detail')
      })
    }

  }
}
</script>

<style scoped lang='scss'>

</style>
